{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 9. Mixture Models and EM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from sklearn.datasets import fetch_mldata\n",
    "%matplotlib inline\n",
    "\n",
    "from prml.clusterings import KMeans\n",
    "from prml.rv import (\n",
    "    MultivariateGaussianMixture,\n",
    "    BernoulliMixture\n",
    ")\n",
    "\n",
    "np.random.seed(1111)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 9.1 K-means Clustering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# training data\n",
    "x1 = np.random.normal(size=(100, 2))\n",
    "x1 += np.array([-5, -5])\n",
    "x2 = np.random.normal(size=(100, 2))\n",
    "x2 += np.array([5, -5])\n",
    "x3 = np.random.normal(size=(100, 2))\n",
    "x3 += np.array([0, 5])\n",
    "x_train = np.vstack((x1, x2, x3))\n",
    "\n",
    "x0, x1 = np.meshgrid(np.linspace(-10, 10, 100), np.linspace(-10, 10, 100))\n",
    "x = np.array([x0, x1]).reshape(2, -1).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARMAAAD8CAYAAABUzEBbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXd8m9X1/9/n0bC8Z/beJIxMAoEACYEQQiBAmW2ZbSmU\n8etglxZKoeVboIxCoZAyWkYLIUCAECCsEGgI2TtkDydxhhNvS3qk+/vjkR3ZkmzZlmxLvu/XSy9L\nz73PoyNL+ujce889R5RSaDQaTUsx2toAjUaTHGgx0Wg0MUGLiUajiQlaTDQaTUzQYqL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nA8OAywPvVzIxMfA+JXKsyUtY351g\nmrzVJWHEJAah+5rWZyywSSm1RSnlAf6D9X5p2hFKqflAcb3DTd7qkjBi0gA9gJ1BjyOF7icSN4vI\nyoD7mcg7qZPxvQlGAfNEZElgu0cyEfVWlxraVeHy1grdb2saep3AM8AfsT6ofwQeBa5tPes0TWC8\nUqpQRDoDn4jI+sCvfFLR2FaXGtqVmMQ5dL/dEO3rFJHngffjbE48Sbj3pikopQoDf/eJyNtYw7pk\nEZMmb3VJhmFOtKH7CUHgjavhAqyJ50TlO2CQiPQTESfWRPnsNrYpJohIuohk1twHJpPY71V9mrzV\npV15Jg0hIhcAfwM6YYXuL1dKnaWUWiMiNaH7JkGh+wnKX0RkBNYwZxvw87Y1p/kopUwRuQn4CLAB\nLwS2WiQDXYC3RQSs79FrSqm5bWtS8xCR14EJQEFge8y9WFtb3hCRnwDbgUsavY4Op9doNLEgGYY5\nGo2mHaDFRKPRxAQtJhqNJiZoMdFoNDFBi4lGo4kJWkw0Gk1M0GKi0Whiwv8Hb2FNM8ZhCMIAAAAA\nSUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10bd1c240>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "kmeans = KMeans(n_clusters=3)\n",
    "kmeans.fit(x_train)\n",
    "cluster = kmeans.predict(x_train)\n",
    "plt.scatter(x_train[:, 0], x_train[:, 1], c=cluster)\n",
    "plt.scatter(kmeans.centers[:, 0], kmeans.centers[:, 1], s=200, marker='X', lw=2, c=['purple', 'cyan', 'yellow'], edgecolor=\"white\")\n",
    "plt.contourf(x0, x1, kmeans.predict(x).reshape(100, 100), alpha=0.1)\n",
    "plt.xlim(-10, 10)\n",
    "plt.ylim(-10, 10)\n",
    "plt.gca().set_aspect('equal', adjustable='box')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## 9.2 Mixture of Gaussians"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARMAAAD8CAYAAABUzEBbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXl8VNX5/98neyaERVkEFJcKItaCBRXrvn4RK6g/qta1\ntC6tu7S22vp1qdqqX611LUVrXequgGhREaVaRbTgrqAiUhYRRFQgIRv5/P44M8lk5k4yk8xkJsnz\nntd9zcw95977zA33wznPec5znCQMwzDaSl62DTAMo3NgYmIYRlowMTEMIy2YmBiGkRZMTAzDSAsm\nJoZhpIW0iIlz7m7n3Brn3PtR+7Zwzj3vnPsk/N4rwbFjnHMfOecWO+cuToc9hmG0P+lqmdwDjInZ\ndzHwgqTBwAvh701wzuUDtwOHA8OAHzvnhqXJJsMw2pG0iImkl4F1MbvHA/eGP98LHBVw6B7AYklL\nJNUAD4ePMwyjg1GQwXP3k7Qq/PkLoF9AnYHA8qjvK4A9g07mnDsDOAOgrKxs5NChQ9NoqmEY0SxY\nsGCtpD6pHJNJMWlAkpxzbYrblzQFmAIwatQozZ8/Py22GYYRj3Puv6kek8nRnNXOuf4A4fc1AXVW\nAttEfd86vM8wjA5GJsVkBnBq+POpwJMBdf4DDHbObe+cKwKODx9nGEYHI11Dww8BrwE7OedWOOd+\nBlwLHOqc+wQ4JPwd59wA59xMAEl1wDnAc8BC4FFJH6TDJsMw2pe0+Ewk/ThB0cEBdT8HxkZ9nwnM\nTIcdhmFkD4uANQwjLZiYGIaRFkxMDMNICyYmhmGkBRMTwzDSgomJYRhpwcTEMIy0YGJiGEZaMDEx\nDCMtmJgYhpEWTEwMw0gLJiaGYaQFExPDMNKCiYlhGGnBxMQwjLRgYmIYRlowMTHST2UlbNyYbSuM\ndsbExEgfy5fDIYdAjx7QqxfsvTd8/HG2rTLaiYyKiXNuJ+fc21HbeufcBTF1DnDOf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JXnpKW+zOYTrr\n74LO+9vsd4VxUkI3hWEYRtJYBKxhGGnBxMQwjLTQYcSkraH7HQXn3BXOuZXOubfD29hs29QWnHNj\nwn+Xxc65ThXh7Jxb6px7L/x3SnkoNVdwzt3tnFsTHbvVmqkuHUZMaHvofkfiJkkjwtvMbBvTWsJ/\nh9uBw4FhwI/Df6/OxIHhv1NHjjW5B//sRJPyVJcOIyZpCN032p89gMWSlkiqAR7G/72MHELSy8C6\nmN0pT3XpMGLSDAOB5VHfE4XudyTOdc69G25+duSZ1J3xbxONgNnOuQXh6R6diaSnukTIqYXL2yt0\nP9s09zuBvwBX4f+hXgXcCPy0/awzUmAfSSudc32B551zi8L/y3cqWprqEiGnxCTDofs5Q7K/0zl3\nJ/B0hs3JJB3ub5MKklaG39c456bhu3WdRUxSnurSGbo5yYbudwjCf7gIR+Mdzx2V/wCDnXPbO+eK\n8I7yGVm2KS0458qcc+WRz8BhdOy/VSwpT3XJqZZJczjnjgZuBfrgQ/fflvQ/kj5wzkVC9+uICt3v\noFzvnBuB7+YsBc7MrjmtR1Kdc+4c4DkgH7g7PNWiM9APmOacA/8cPSjp2eya1Dqccw8BBwC9w9Nj\nLsdPbXnUOfcz4L/AsS2ex8LpDcNIB52hm2MYRg5gYmIYRlowMTEMIy2YmBiGkRZMTAzDSAsmJoZh\npAUTE8Mw0sL/B7kFZWw891/6AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1139bb3c8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "gmm = MultivariateGaussianMixture(n_components=3)\n",
    "gmm.fit(x_train)\n",
    "p = gmm.classify_proba(x_train)\n",
    "\n",
    "plt.scatter(x_train[:, 0], x_train[:, 1], c=p)\n",
    "plt.scatter(gmm.mu[:, 0], gmm.mu[:, 1], s=200, marker='X', lw=2, c=['red', 'green', 'blue'], edgecolor=\"white\")\n",
    "plt.xlim(-10, 10)\n",
    "plt.ylim(-10, 10)\n",
    "plt.gca().set_aspect(\"equal\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### 9.3.3 Mixtures of Bernoulli distributions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "mnist = fetch_mldata(\"MNIST original\")\n",
    "x = mnist.data\n",
    "y = mnist.target\n",
    "x_train = []\n",
    "for i in [0, 1, 2, 3, 4]:\n",
    "    x_train.append(x[np.random.choice(np.where(y == i)[0], 200)])\n",
    "x_train = np.concatenate(x_train, axis=0)\n",
    "x_train = (x_train > 127).astype(np.float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABIEAAADjCAYAAAASRQSDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAH/NJREFUeJzt3VlzVNf9NeCDMfMgkEAS82TAxtgmjuOKq/IJ8qVdvkhV\nyhUPBMfExiCwGAUIgcQgieF//779Ww4HNLGf57JXne7T3WefvXujYq179epVBwAAAMC77b2VPgEA\nAAAAlp5NIAAAAIAG2AQCAAAAaIBNIAAAAIAG2AQCAAAAaIBNIAAAAIAG2AQCAAAAaIBNIAAAAIAG\n2AQCAAAAaMD7y/li69ate7WcrwerzatXr9at9DkMYmzSOmMTVidjE1YnYxNWp/9lbPpLIAAAAIAG\n2AQCAAAAaIBNIAAAAIAG2AQCAAAAaIBNIAAAAIAG2AQCAAAAaMCyVsQDAACshHXr6ubkV680iwNt\n8JdAAAAAAA2wCQQAAADQAJtAAAAAAA2wCQQAAADQAJtAAAAAAA2wCQQAAADQABXx/CF1mgAAa0ta\nv60V7703+N+rX758WR5jbQqQ+UsgAAAAgAbYBAIAAABogE0gAAAAgAbYBAIAAABogE0gAAAAgAbY\nBAIAAABogIr4VSxVe6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X8JBAAAANAAm0AAAAAADbAJBAAAANAAm0AAAAAADbAJ\nBAAAANAAm0AAAAAADVAR/5b0rcNOFYEvXrx4o3N6nfNQ57481GmuLmlMpDrbVHudxlI1pvvWxC4s\nLJRZurekWsxW7wXG5rshjem1UOvK/8/Y5F2V7lfJarmXGZv9pTVaypJ0PaVq9iStMyvp/NM59v3d\nm45L6913mYp4AAAAALquswkEAAAA0ASbQAAAAAANsAkEAAAA0ACbQAAAAAANsAkEAAAA0AAV8bCM\n1GkySN+a2GS1VMiuFcYmrE7GJqxOxubakdaZb3u9uJyvxWAq4gEAAADous4mEAAAAEATbAIBAAAA\nNMAmEAAAAEADbAIBAAAANMAmEAAAAEAD3l/pEwBoncpMAACWwnKuM61p1wZ/CQQAAADQAJtAAAAA\nAA2wCQQAAADQAJtAAAAAAA2wCQQAAADQAJtAAAAAAA1Yp8YNAAAA4N3nL4EAAAAAGmATCAAAAKAB\nNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAA\nAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmAT\nCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGvB/JnyQXFCaRKEAAAAA\nSUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1140caf28>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "bmm = BernoulliMixture(n_components=5)\n",
    "bmm.fit(x_train)\n",
    "\n",
    "plt.figure(figsize=(20, 5))\n",
    "for i, mean in enumerate(bmm.mu):\n",
    "    plt.subplot(1, 5, i + 1)\n",
    "    plt.imshow(mean.reshape(28, 28), cmap=\"gray\")\n",
    "    plt.axis('off')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
